home *** CD-ROM | disk | FTP | other *** search
- {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- TechInsite Pty. Ltd.
- PO Box 429, Abbotsford, Melbourne. 3067 Australia
- Phone: +61 3 9419 6456
- Fax: +61 3 9419 1682
- Web: www.techinsite.com.au
- EMail: peter_hinrichsen@techinsite.com.au
-
- Created: 01/06/1999
-
- Notes: Family of TAnimal descendants for factory demo
-
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
- unit Animals;
-
- interface
- uses
- Classes
- ;
-
- type
-
- TAnimal = class( TObject )
- public
- Procedure Talk ; virtual ; abstract ;
- end ;
-
- TDog = class( TAnimal )
- public
- Procedure Talk ; override ;
- end ;
-
- TCat = class( TAnimal )
- public
- Procedure Talk ; override ;
- end ;
-
- TBird = class( TAnimal )
- public
- Procedure Talk ; override ;
- end ;
-
- implementation
- uses
- Dialogs
- ,FactoryConcreteAnimal
- ,Constants
- ;
-
- { TDog }
-
- procedure TDog.Talk;
- begin
- showMessage( 'Woof' ) ;
- end;
-
- { TCat }
-
- procedure TCat.Talk;
- begin
- ShowMessage( 'Meow' ) ;
- end;
-
- { TBird }
-
- procedure TBird.Talk;
- begin
- ShowMessage( 'Tweet' ) ;
- end;
-
- initialization
-
- // Register the classes with the animal factory. Note the third parameter
- // is true which so these objects will be cached once they are created.
- gFactoryConcreteAnimal.RegisterClass( cgStrAnimalDog,
- TDog,
- True ) ;
-
- gFactoryConcreteAnimal.RegisterClass( cgStrAnimalCat,
- TCat,
- True ) ;
-
- gFactoryConcreteAnimal.RegisterClass( cgStrAnimalBird,
- TBird,
- True ) ;
-
-
- end.
-